home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / tstse13.zip / MISC.S < prev    next >
Text File  |  1994-11-26  |  4KB  |  152 lines

  1. /* Miscellaneous additional commands for SemWare's TSE editor V2.0.
  2.    To make this SAL macro operational, invoke the main menu (F10),
  3.    choose "Macro", choose "Compile" and press Enter at "Execute
  4.    Macro".
  5.  
  6. ..................................................................
  7. Prof. Timo Salmi      Co-moderator of comp.archives.msdos.announce
  8. Moderating at garbo.uwasa.fi anonymous FTP archives  193.166.120.5
  9. Faculty of Accounting & Industrial Management; University of Vaasa
  10. Internet: ts@uwasa.fi   BBS +(358)-61-3170972; FIN-65101,  Finland
  11. */
  12.  
  13. // The contents of a simple help, tied later to the CtrlAlt-H key
  14. helpdef tHelpData
  15.   title = "MISC.S HELP"           // The help's caption
  16.   x = 10                          // Location
  17.   y = 3
  18.   // The actual help text
  19.   " Prof. Timo Salmi's miscellania"
  20.   ""
  21.   " You can use <F11> to invoke the command "
  22.   " menu after first exiting this help. "
  23.   ""
  24.   " Last updated Sat 26-November-1994 19:46:56 "
  25. end  /* tHelpData */
  26.  
  27. // File name options ***************************************************
  28. proc timoInsertFileName()
  29.   string fn[80]
  30.   fn = Upper(SplitPath(CurrFilename(),_NAME_))
  31.   fn = fn + Upper(SplitPath(CurrFilename(),_EXT_))
  32.   InsertText(fn)
  33. end timoInsertFileName
  34.  
  35. proc timoInsertFullFilename()
  36.   InsertText(Upper(CurrFilename()), _DEFAULT_)
  37. end timoInsertFullFileName
  38.  
  39. // For timoGoDown and timoGoUp **************************************
  40. string linesToGoUpDown[22] = "50"
  41. integer goupdown_hist
  42.  
  43. // Advance the cursor for manual paging
  44. proc timoGoDown()
  45.   integer n = 0
  46.   integer i = 0
  47.   integer ok = FALSE
  48.   ok = Ask("Number of lines down: ", linesToGoUpDown, goupdown_hist)
  49.   if ok and Length(linesToGoUpDown) > 0
  50.     n = Val(linesToGoUpDown)
  51.     while i < n
  52.       i = i + 1
  53.       Down()
  54.     endwhile
  55.   endif
  56. end
  57.  
  58. proc timoGoUp()
  59.   integer n = 0
  60.   integer i = 0
  61.   integer ok = FALSE
  62.   ok = Ask("Number of lines up: ", linesToGoUpDown, goupdown_hist)
  63.   if ok and Length(linesToGoUpDown) > 0
  64.     n = Val(linesToGoUpDown)
  65.     while i < n
  66.       i = i + 1
  67.       Up()
  68.     endwhile
  69.   endif
  70. end
  71.  
  72. // Find the longest line ***********************************************
  73. proc timoMaxLength()
  74.   integer m, r
  75.   BegFile()
  76.   m = CurrLineLen()
  77.   r = CurrLine()
  78.   while Down()
  79.     if CurrLineLen() > m
  80.       m = CurrLineLen()
  81.       r = CurrLine()
  82.     endif
  83.   endwhile
  84.   GotoLine(r)
  85.   BegLine()
  86.   ScrollToRow(Query(WindowRows) / 2)
  87.   Message ('Longest line ', Str(r), ', length ', Str(m))
  88. end timoMaxLength
  89.  
  90. // Send the current line to the printer ********************************
  91. proc timoPrintLine()
  92.   PushBlock()
  93.   UnmarkBlock()
  94.   MarkLine()
  95.   PrintBlock()
  96.   UnmarkBlock()
  97.   Down()
  98.   PopBlock()
  99. end timoPrintLine
  100.  
  101. // New keys and menus **************************************************
  102. forward Menu tMiscMenu()
  103. forward proc tDisableNewKeys()
  104.  
  105. // Add the new key definitions
  106. keydef new_keys
  107.   <CtrlAlt 1>      timoInsertFilename()
  108.   <CtrlAlt 2>      timoInsertFullFilename()
  109.   <CtrlAlt 3>      timoGoDown()
  110.   <CtrlAlt 4>      timoGoUp()
  111.   <CtrlAlt 5>      timoMaxLength()
  112.   <CtrlAlt 6>      timoPrintLine()
  113.   <CtrlAlt 0>      tDisableNewKeys()
  114.   <CtrlAlt H>      QuickHelp(tHelpData)
  115.   <F11>            tMiscMenu()
  116. end
  117.  
  118. // Disabling the new extra keys ***************************************
  119. proc tDisableNewKeys()
  120.   if YesNo("Disable the extra keys:") == 1
  121.     Disable(new_keys)
  122.     DelHistory(goupdown_hist)
  123.   endif
  124. end
  125.  
  126. // The miscellaneous routines menu ************************************
  127. Menu tMiscMenu()
  128.   Title = "Type file name"
  129.   x = 40
  130.   y = 3
  131.   history
  132.   "&Insert filename      <CtrlAlt 1>"   , timoInsertFilename()
  133.   "Insert &full filename <CtrlAlt 2>"   , timoInsertFullFilename()
  134.   "Manual paging",,Divide
  135.   "Lines &Down...        <CtrlAlt 3>"   , timoGoDown()
  136.   "Lines &Up...          <CtrlAlt 4>"   , timoGoUp()
  137.   "Find",,Divide
  138.   "&Goto longest line    <CtrlAlt 5>"   , timoMaxLength()
  139.   "Print",,Divide
  140.   "&Print current line   <CtrlAlt 6>"   , timoPrintLine()
  141.   "Administer",,Divide
  142.   "Disable new &keys     <CtrlAlt 0>"   , tDisableNewKeys()
  143.   "&Help                 <CtrlAlt H>"   , QuickHelp(tHelpData)
  144.   "This Menu            <F11>"
  145. end  /* tMiscMenu */
  146.  
  147. proc Main()
  148.   goupdown_hist = GetFreeHistory()
  149.   Enable (new_keys)
  150.   tMiscMenu()
  151. end
  152.